package com.xjrsoft.module.customerTwo.AppManage.daykpi.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjrsoft.core.tool.utils.StringUtil;
import com.xjrsoft.module.customerTwo.AppManage.daykpi.entity.DwDayKpiData;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.xjrsoft.core.tool.utils.CollectionUtil;
import java.util.ArrayList;
import com.xjrsoft.module.customerTwo.AppManage.daykpi.dto.DwDayKpiDataListDto;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import java.util.List;
import com.xjrsoft.module.customerTwo.AppManage.daykpi.mapper.DwDayKpiDataMapper;
import com.xjrsoft.module.customerTwo.AppManage.daykpi.service.IDwDayKpiDataService;
import com.xjrsoft.core.mp.base.BaseService;
import com.xjrsoft.core.tool.utils.Func;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

/**
 *  服务实现类
 *
 * @author lisen
 * @since 2024-05-31
 */
@Service
@AllArgsConstructor
public class DwDayKpiDataServiceImpl extends BaseService<DwDayKpiDataMapper, DwDayKpiData> implements IDwDayKpiDataService {


	@Override
	public IPage<DwDayKpiData> getPageList(DwDayKpiDataListDto pageListDto) {
		Wrapper<DwDayKpiData> wrapper = Wrappers.<DwDayKpiData>query().lambda()
				.like(!StringUtil.isEmpty(pageListDto.getCompany_id()), DwDayKpiData::getCompanyId, pageListDto.getCompany_id())
				.ge(!StringUtil.isEmpty(pageListDto.getCreate_date_Start()), DwDayKpiData::getCreateDate, pageListDto.getCreate_date_Start())
				.le(!StringUtil.isEmpty(pageListDto.getCreate_date_End()), DwDayKpiData::getCreateDate, pageListDto.getCreate_date_End())
				.eq(!StringUtil.isEmpty(pageListDto.getPurchase_order_count()), DwDayKpiData::getPurchaseOrderCount, pageListDto.getPurchase_order_count())
				.eq(!StringUtil.isEmpty(pageListDto.getOrder_number()), DwDayKpiData::getOrderNumber, pageListDto.getOrder_number())
				.eq(!StringUtil.isEmpty(pageListDto.getProduction_number()), DwDayKpiData::getProductionNumber, pageListDto.getProduction_number())
				.ge(!StringUtil.isEmpty(pageListDto.getUpdate_date_Start()), DwDayKpiData::getUpdateDate, pageListDto.getUpdate_date_Start())
				.le(!StringUtil.isEmpty(pageListDto.getUpdate_date_End()), DwDayKpiData::getUpdateDate, pageListDto.getUpdate_date_End())
				.like(!StringUtil.isEmpty(pageListDto.getCreater()), DwDayKpiData::getCreater, pageListDto.getCreater())
				.like(!StringUtil.isEmpty(pageListDto.getUpdater()), DwDayKpiData::getUpdater, pageListDto.getUpdater());
		return this.page(ConventPage.getPage(pageListDto), wrapper);
	}

	@Override
	public Integer addDwDayKpiData(DwDayKpiData dwDayKpiData) {
		boolean isSuccess = this.save(dwDayKpiData);
		return isSuccess ? dwDayKpiData.getId() : null;
	}

	@Override
	public boolean updateDwDayKpiData(Integer id, DwDayKpiData dwDayKpiData) {
		dwDayKpiData.setId(id);
		return this.updateById(dwDayKpiData);
	}

	public boolean delete(String ids) {
		List<String> idList = Func.toStrList(ids);
		if (this.removeByIds(idList)) {
			return true;
		}
		return false;
	}

}